package edu.office.applicationRepository;

import io.quarkus.hibernate.orm.panache.PanacheRepository;

/**
 * @author haogs
 */
public class ApplicationCommonRepository<T> implements PanacheRepository<T> {

    //数据库中数据是否更新    
    protected boolean dataChanged = true;//一开始的时候，要获取数据

    public boolean isDataChanged() {
        return dataChanged;
    }

    public void setDataChanged(boolean dataChanged) {
        if (this.dataChanged != dataChanged) {//读比写要快得多
            this.dataChanged = dataChanged;
        }
    }

    public void create(T t) {
        persist(t);
        setDataChanged(true);
    }

    public void edit() {
        setDataChanged(true);
    }

    public void destroy(T t) {
        delete(t);
        setDataChanged(true);
    }

}
